//
//  EarbudsFindPopView.swift
//  EasePods
//
//  Created by 易先生 on 2024/5/6.
//

import UIKit
import SnapKit

class EarbudsFindPopView: View {

    public var confirmBlock : (() -> Void)?
    
    override func makeUI() {
        super.makeUI()
        self.addSubview(iconImageView)
        self.addSubview(titleLabel)
        self.addSubview(descLabel)
        self.addSubview(confirmButton)

        iconImageView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(40)
            make.centerX.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(iconImageView.snp.bottom).offset(20)
            make.leading.equalToSuperview().offset(20)
            make.centerX.equalToSuperview()
        }
        
        descLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(12)
            make.leading.equalToSuperview().offset(20)
            make.centerX.equalToSuperview()
        }
        
        confirmButton.snp.makeConstraints { make in
            make.top.equalTo(descLabel.snp.bottom).offset(12)
            make.leading.equalToSuperview().offset(20)
            make.centerX.equalToSuperview()
            make.height.equalTo(57)
            make.bottom.equalToSuperview().offset(-50)
        }
    }
    
    
    @objc private func click_confirm() {
        
        confirmBlock?()
    }

    private lazy var iconImageView: ImageView = {
        let imageView = ImageView()
        imageView.image = R.image.img_earbuds_find_warn()
        return imageView
    }()
    
    private lazy var titleLabel: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 18)
        label.textColor = R.color.common_3_text()
        label.numberOfLines = 0
        label.text = R.string.localizable.earbuds_find_pop_title()
        label.textAlignment = .center
        return label
    }()
    
    private lazy var descLabel: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 14)
        label.textColor = R.color.common_23_text_second()
        label.numberOfLines = 0
        label.text = R.string.localizable.earbuds_find_pop_desc()
        label.textAlignment = .center
        return label
    }()
    
    private lazy var confirmButton: UIButton = {
        let button = UIButton()
        button.setTitle(R.string.localizable.common_confirm(), for: .normal)
        button.setTitleColor(R.color.common_24_button_text(), for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 16)
        button.titleLabel?.numberOfLines = 0
        button.backgroundColor = R.color.common_22_button_n()
        button.layer.cornerRadius = 6
        button.addTarget(self, action: #selector(click_confirm), for: .touchUpInside)
        return button
    }()

}
